#include "group.h"
#include "config.h"
#include <vector>
#include <list>
#include <iostream>

#define vector std::vector
#define list std::list

vector<BulletInfo> bulletGroup;
vector<ArmyInfo> armyGroup;

using std::cerr;
using std::endl;

const BulletInfo *getBullet(uint32_t index){
    if (index <= bulletGroup.size()){
#if USE_LOG
        DEBUG_SPLIT();
        cerr << "访问一个根本不存在的子弹: " << index << endl;
        DEBUG_SPLIT();
#endif
        return NULL;
    }
    return &bulletGroup[index];
}

const ArmyInfo *getArmy(uint32_t index){
    if (index <= armyGroup.size()){
#if USE_LOG
        DEBUG_SPLIT();
        cerr << "访问一个根本不存在的军队: " << index << endl;
        DEBUG_SPLIT();
#endif
        return NULL;
    }
    return &armyGroup[index];
}

BulletInfo::BulletInfo(const BulletInfo &b){
    name = b.name;
    imagePath = b.imagePath;
    attackNum = b.attackNum;
    velocity = b.velocity;
}

BulletInfo::BulletInfo(BulletInfo &&b){
    name = std::move(b.name);
    imagePath = std::move(b.imagePath);
    attackNum = b.attackNum;
    velocity = b.velocity;
}

BulletInfo &BulletInfo::operator=(const BulletInfo &b){
    name = b.name;
    imagePath = b.imagePath;
    attackNum = b.attackNum;
    velocity = b.velocity;
    return *this;
}

BulletInfo &BulletInfo::operator=(BulletInfo &&b){
    name = std::move(b.name);
    imagePath = std::move(b.imagePath);
    attackNum = b.attackNum;
    velocity = b.velocity;
    return *this;
}

ArmyInfo::ArmyInfo(const ArmyInfo &a){
    name = a.name;
    imagePath = a.imagePath;
    lifeLimit = a.lifeLimit;
    defend = a.defend;
    consumeTime = a.consumeTime;
    consumeMoney = a.consumeMoney;
    consumeEnergy = a.consumeEnergy;
}

ArmyInfo::ArmyInfo(ArmyInfo &&a){
    name = std::move(a.name);
    imagePath = std::move(a.name);
    lifeLimit = a.lifeLimit;
    defend = a.defend;
    consumeTime = a.consumeTime;
    consumeMoney = a.consumeMoney;
    consumeEnergy = a.consumeEnergy;
}

ArmyInfo &ArmyInfo::operator=(const ArmyInfo &a){
    name = a.name;
    imagePath = a.imagePath;
    lifeLimit = a.lifeLimit;
    defend = a.defend;
    consumeTime = a.consumeTime;
    consumeMoney = a.consumeMoney;
    consumeEnergy = a.consumeEnergy;
    return *this;
}

ArmyInfo &ArmyInfo::operator=(ArmyInfo &&a){
    name = std::move(a.name);
    imagePath = std::move(a.name);
    lifeLimit = a.lifeLimit;
    defend = a.defend;
    consumeTime = a.consumeTime;
    consumeMoney = a.consumeMoney;
    consumeEnergy = a.consumeEnergy;
    return *this;
}

uint32_t registerBullet(const BulletInfo &b){
    bulletGroup.push_back(b);
    return bulletGroup.size() - 1;
}

uint32_t registerArmy(const ArmyInfo &a){
    armyGroup.push_back(a);
    return bulletGroup.size() - 1;
}

